package com.ht.medicaltreatment.adapter

import android.graphics.Color
import android.text.TextUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.Row

class SampleListAdapter : BaseQuickAdapter<Row,BaseViewHolder>(R.layout.item_sample_layout){

    override fun convert(holder: BaseViewHolder, item: Row) {
        holder.setText(R.id.tvName,item.name)
        holder.setText(R.id.tvLocation,"位置信息： ${item.sampleStru?.detailLocation}")
        if(item.status == 1){
            holder.setText(R.id.tvState,"正常")
            holder.setBackgroundResource(R.id.tvState,R.drawable.shape_sample_item_state_green)
        }else{
            holder.setText(R.id.tvState,"借出")
            holder.setBackgroundResource(R.id.tvState,R.drawable.shape_sample_item_state_blue)
        }

        if(item.rfidCode.contains("sample")){
            holder.setText(R.id.rfid,"待绑定")
            holder.setTextColor(R.id.rfid,Color.RED)
        }else{
            holder.setText(R.id.rfid,item.rfidCode)
            holder.setTextColor(R.id.qr,Color.BLACK)
        }

        if(TextUtils.isEmpty(item.barCode)){
            holder.setText(R.id.qr,"待绑定")
            holder.setTextColor(R.id.qr,Color.RED)
        }else{
            holder.setText(R.id.qr,item.barCode)
            holder.setTextColor(R.id.qr,Color.BLACK)
        }
    }
}
